﻿using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace DesktopToyWpf.Convertors;

/// <summary>
/// 大于等于某个数就切换颜色
/// </summary>
public class GreaterThanOrEqualToColorConvertor : IValueConverter
{
    public Brush NormalBrush { get; set; }
    public Brush GreaterThanBrush { get; set; }

    public double Value { set; get; }

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value switch
        {
            int intValue => intValue >= Value ? GreaterThanBrush : NormalBrush,
            float floatValue => floatValue >= Value ? GreaterThanBrush : NormalBrush,
            double doubleValue => doubleValue >= Value ? GreaterThanBrush : NormalBrush,
            _ => NormalBrush
        };
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}